﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using HZ.DrugTrade.Web;

namespace WebDemo.webeditor
{
    public partial class InsertToEdittor : BasePage
    {
        protected string insertcode = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            string type = Request.QueryString["type"]; // type可能img,doc,xls
            string url = Request.QueryString["url"];
            string originname = Request.QueryString["filename"];
            insertcode = GetInsertCode(type, url, originname);
        }
        /// <summary>
        /// 获取插入代码
        /// </summary>
        /// <param name="type">上传的类型</param>
        /// <param name="url">上传文件的地址</param>
        /// <param name="filename">原始文件名</param>
        /// <returns></returns>
        private string GetInsertCode(string type, string url, string filename)
        {
            if (type == "img") // 图片插入代码
            {
                return string.Format("<img src=\"{0}\" />", url);
            }
            else //其他类型直接插入链接
            {
                return string.Format("<a href=\"{0}\">{1}</a>", url, filename);
            }
        }
    }
}
